package com.example.auto_rental.utils;

import jakarta.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;


/**
 * @Name: RedisUtils
 * @Author: Jovan
 * @Date: 2024/9/12 17:04
 * @Description: Redis的工具类
 */
@Component
public class RedisUtils {
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    /*
    * 设置值
    * @param key 键
    * @param value 值
    * @param timeout 超时时间
    * */
    public void set(String key,String value,Long timeout){
        stringRedisTemplate.opsForValue().set(key,value,timeout,TimeUnit.SECONDS);
    }
}
